﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Text;

namespace Hongapo_Services
{
    public class UIPage : System.Web.UI.Page
    {

        private void PageBase_Load(object sender, EventArgs e)
        {


        }
        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                base.OnLoad(e);
            }
        }

        #region 生成点击高的商品
        /// <summary>
        /// 生成点击高的商品
        /// </summary>
        /// <returns></returns>
        public static string CreateHotGoods()
        {
            StringBuilder str = new StringBuilder();
            DataTable dt = new Product.Product().GetList(10, " isopen=1", " Clicks Desc ").Tables[0];
            str.Append("<div class=\"right_sider\"><div class=\"rt_news_list\"><h3>人气最旺</h3><ul class=\"rtnews_listul\">");
            foreach (DataRow dr in dt.Rows)
            {
                str.Append("<li><a href=\"goods.aspx?ID=" + dr["ID"] + "\" target=\"_blank\">" + Hongapo_Common.StringUtils.CutString(dr["title"].ToString(), 30) + " (" + dr["clicks"] + ")</a></li>");
            }
            str.Append("</ul></div></div>");
            return str.ToString();
        //     <div class="right_sider">
        //    <div class="rt_news_list">
        //        <h3>人气最旺</h3>
        //        <ul class="rtnews_listul">
        //            <li><a href="#"></a></li>
        //        </ul>
        //    </div>
            
        //</div>

        }
        #endregion

        #region 消息提示
        public void Show(string msg)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
        }

        public void Show(string msg, string url)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>");
        }

        /// <summary>
        /// 输出自定义脚本信息
        /// </summary>
        /// <param name="page">当前页面指针，一般为this</param>
        /// <param name="script">输出脚本</param>
        public void ResponseScript(string script)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "message", "<script language='javascript' defer>" + script + "</script>");

        }
        #endregion

    }
}
